{
	template:`
    <m-page @back="back" title="店铺计划">
        <template #nav>
            <div class="nav text-center bg-gray">
                <div v-for="year in years" class="cu-item" :class="year==selectYear?'text-blue cur':''" @click="selectItem(year)">{{year}}</div>
            </div>
        </template>
        <template #bar>
            <div class="flex-sub padding-lr text-sm text-right">
                年度合计：{{formatAmount(model.planAll)}}元
            </div>
            <div class="m-buttons padding-right">
                <m-button @click="save()">保存</m-button>
            </div>
        </template>
        <m-card>
            <div class="flex padding-sm align-center">
                <div class="cu-tag radius" :class="'bg-'+model.inputStore.color">{{model.inputStore.name}}</div>
                <div class="flex-sub padding-lr-sm">
                    <div class="text-sm">{{model.inputStore.address}}</div>
                    <div class="padding-top-xs">{{model.inputStore.tel}}</div>
                </div>
            </div>
        </m-card>
        <m-title>{{model.planYear}}年销售计划（单位：元）</m-title>
        <m-card>
            <div class="padding-xs">
                <m-grid :col="2">
                    <m-desc v-for="m in months" :title="parseInt(m)+'月'">
                        <div class="padding-lr padding-tb-xs text-align" style="min-height:30px;">
                            <m-input-number v-model="model['plan'+m]" format="#,##0" placeholder="请输入计划金额" @change="countPlanAll"></m-input-number>
                        </div>
                    </m-desc>
                </m-grid>
            </div>
        </m-card>
    </m-page>
	`,
	props: ['param','parentVue'],
	data:function(){
		return {
		    selectYear:'',
		    years:[],
		    months:['01','02','03','04','05','06','07','08','09','10','11','12'],
		    model:{inputStore:{}}
		};
	},
	mounted(){
	    let y=new Date().getFullYear();
	    for(let i=y-2;i<=y+2;i++) this.years.push(i);
	    this.selectItem(y);
	},
	methods:{
	    selectItem:function(y){
	        this.selectYear=y;
	        this.loadModel();
	    },
	    loadModel:function(){
            this.requestData('action/order/storePlan/getYear',
                {year:this.selectYear},
                (data)=>{
                    if(data.code==0){
                        this.model=data.model;
                    }else{
                        this.remind().error(data.msg);
                    }
                }
            );
	    },
	    countPlanAll:function(){
	        let all=0.0;
	        for(let i=0;i<this.months.length;i++){
	            all+=this.model['plan'+this.months[i]]||0;
	        }
	        this.model.planAll=all;
	    },
	    save:function(){
            this.requestData('action/order/storePlan/save',
                {model:this.model},
                (data)=>{
                    if(data.code==0){
                        this.remind().success(data.msg);
                        this.back(true);
                    }else{
                        this.remind().error(data.msg);
                    }
                }
            );
	    }
	}
}